package com.gc.business.service.impl;

import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.gc.common.utils.StringUtils;
import org.springframework.stereotype.Service;
import com.gc.business.mapper.ElevatorEventMapper;
import com.gc.business.domain.ElevatorEvent;
import com.gc.business.service.IElevatorEventService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;

/**
 * 电梯事件 服务层实现
 * 
 * @author hruiyan
 * @date 2020-11-16
 */
@Slf4j
@Service
public class ElevatorEventServiceImpl extends ServiceImpl<ElevatorEventMapper, ElevatorEvent> implements IElevatorEventService {

    @Override
    public List<ElevatorEvent> list(ElevatorEvent elevatorEvent){
        LambdaQueryWrapper<ElevatorEvent> wrapper = new LambdaQueryWrapper<>();
        if(elevatorEvent != null){
            if(StringUtils.isNotEmpty(elevatorEvent.getEventId())){
                wrapper.eq(ElevatorEvent::getEventId, elevatorEvent.getEventId());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getElevatorId())){
                wrapper.eq(ElevatorEvent::getElevatorId, elevatorEvent.getElevatorId());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getEventCode())){
                wrapper.eq(ElevatorEvent::getEventCode, elevatorEvent.getEventCode());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getElevatorName())){
                wrapper.like(ElevatorEvent::getElevatorName, elevatorEvent.getElevatorName());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getUseUnit())){
                wrapper.like(ElevatorEvent::getUseUnit, elevatorEvent.getUseUnit());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getServerUnit())){
                wrapper.like(ElevatorEvent::getServerUnit, elevatorEvent.getServerUnit());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getEventType())){
                wrapper.eq(ElevatorEvent::getEventType, elevatorEvent.getEventType());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getReportTime())){
                wrapper.eq(ElevatorEvent::getReportTime, elevatorEvent.getReportTime());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getRemoveTime())){
                wrapper.eq(ElevatorEvent::getRemoveTime, elevatorEvent.getRemoveTime());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getEventDuration())){
                wrapper.eq(ElevatorEvent::getEventDuration, elevatorEvent.getEventDuration());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getCreateBy())){
                wrapper.eq(ElevatorEvent::getCreateBy, elevatorEvent.getCreateBy());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getCreateTime())){
                wrapper.eq(ElevatorEvent::getCreateTime, elevatorEvent.getCreateTime());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getUpdateBy())){
                wrapper.eq(ElevatorEvent::getUpdateBy, elevatorEvent.getUpdateBy());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getUpdateTime())){
                wrapper.eq(ElevatorEvent::getUpdateTime, elevatorEvent.getUpdateTime());
            }
            if(StringUtils.isNotEmpty(elevatorEvent.getRemark())){
                wrapper.eq(ElevatorEvent::getRemark, elevatorEvent.getRemark());
            }
        }
        return baseMapper.selectList(wrapper);
    }

    /**
     * 数据权限查询
     * @param elevatorEvent
     * @return
     */
    @Override
    public List<ElevatorEvent> selectElevatorEventList(ElevatorEvent elevatorEvent){
        return baseMapper.selectElevatorEventList(elevatorEvent);
    }
}
